<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../lib/bootstrap-3.3.5-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="../css/index.css">
    <link rel="stylesheet" href="../css/mall.css">
    <link rel="stylesheet" href="../css/zx.css">
    <link rel="stylesheet" href="../font/iconfont.css">
    <script src="../lib/bootstrap-3.3.5-dist/js/jquery-1.11.3.js"></script>
    <script src="../lib/bootstrap-3.3.5-dist/js/bootstrap.min.js"></script>

</head>

<body>
    <div class="kong11"></div>
    <div id="mulu">
        <!-- 导航 -->
        <div id="cateHead">
            <p><span>首页 / 商城系统 / </span>售后服务</p>
            <p>售后服务</p>
        </div>
    </div>


    <div id="catemain">
        <div class="catequery">
            <p class="tiaojianp">查询条件</p>
            <div class="row">
                <div class="col-md-3">
                    <label>服务编号:
                        <input type="text" class=" grayborder" id="serviceCode">
                    </label>
                </div>
                <div class="col-md-2">
                    <label>处理状态:
                        <select name="" id="clzt" class="seclewidsaml grayborder">
                            <option value="全部">全部</option>
                            <option value="待处理">待处理</option>
                            <option value="已处理">已处理</option>
                            <option value="已拒绝">已拒绝</option>
                        </select>
                    </label>
                </div>
                <div class="col-md-5">
                    <div class="formtimeto">
                        <label>申请日期:
                            <input type="date" class="mytime1">至
                            <input type="date" class="mytime2">
                        </label>
                    </div>

                </div>
                <div class="col-md-2 mybutn">
                    <button class="myczbutn">重置</button>
                    <button class="myqurbutn">查询</button>
                </div>
            </div>
        </div>
        <div id="tdheight">
            <div class="catetablehead mybutn">
                <p class="tiaojianp">退款列表</p>
                <button class="bigdel mydelbutn">删除数据</button>
            </div>
            <table class="table">
                <thead>
                    <tr>
                        <th> <input type="checkbox" name="" id=""></th>
                        <th>服务编号</th>
                        <th>退款账号</th>
                        <th>退款金额</th>
                        <th>申请时间</th>
                        <th>处理时间</th>
                        <th>处理状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody id="mytbody">
                </tbody>
            </table>
            <div id="pagebut">

            </div>
        </div>
    </div>


    <div>
        <span class="foot1">大健康综合管理后台</span>
        <span class="foot2">版权所有:@大健康综合(集团)有限公司Meinian Onehealth Healthcare (Group)Co.</span>
        <span class="foot2">沪ICP备09017846号-3沪公网安备31010602006448号</span>
    </div>
    <script src="../JavaScript/index.js"></script>
    <script src="../JavaScript/data.js"></script>
    <script src="../JavaScript/mall.js"></script>
    <script src="../JavaScript/utils.js"></script>

    <script>
        var querydata = []
        showTable(6, after_salesData)
        function mysepcil() {

            let sepc1 = document.querySelectorAll('#mytbody td:nth-of-type(1)')
            let sepc2 = document.querySelectorAll('#mytbody td:last-of-type')
            $(sepc1).before(`<td><input type="checkbox" name="" id="" class="check"></td>`)
            for (let o = 0; o < sepc2.length; o++) {
                $(sepc2[o]).after(`<td><a href="">立即处理</a></td>`)
            }
            $(`td>button`).css({
                margin: '0 10px',
                backgroundColor: '#fff',
                color: 'rgba(24, 144, 255, 1)'
            })
            checkfun()
        }
        // 查询需要的数组
        let txarry = []
        $('.myqurbutn').click(function () {

            for (let i = 0; i < after_salesData.length; i++) {
                if (after_salesData[i].serviceCode == $('#serviceCode').val() && $('#clzt').val() == '全部' && $('.mytime1').val() == '' && $('.mytime2').val() == '') {

                    txarry.push(after_salesData[i])

                }
                if (after_salesData[i].serviceCode == $('#serviceCode').val() && after_salesData[i].dealStatus == $('#clzt').val() && $('.mytime1').val() == '' && $('.mytime2').val() == '') {
                    txarry.push(after_salesData[i])
                }
                let oldtime = new Date(after_salesData[i].applyTime)
                let newtimesaml = new Date($('.mytime1').val())
                let newtimebig = new Date($('.mytime2').val())
                if (after_salesData[i].serviceCode == $('#serviceCode').val() && after_salesData[i].dealStatus == $('#clzt').val() && oldtime >= newtimesaml && oldtime <= newtimebig) {
                    txarry.push(after_salesData[i])
                }
                if ($('#serviceCode').val() == '' && after_salesData[i].dealStatus == $('#clzt').val() && $('.mytime1').val() == '' && $('.mytime2').val() == '') {
                    console.log(123);
                    txarry.push(after_salesData[i])
                }
                if ($('#serviceCode').val() == '' && $('#clzt').val() == '全部' && oldtime >= newtimesaml && oldtime <= newtimebig) {
                    txarry.push(after_salesData[i])
                }
                if ($('#serviceCode').val() == '' && after_salesData[i].dealStatus == $('#clzt').val() && oldtime >= newtimesaml && oldtime <= newtimebig) {
                    txarry.push(after_salesData[i])
                }
            }
            // console.log(txarry);
            showTable(6, txarry)
            txarry = []
            // }
        })
        $(".myczbutn").click(function () {
            showTable(6, after_salesData)
            // $('.mytime1').val() = ''
            // $('.mytime2').val() = ''
            $('#serviceCode').val() == ''
            $('#clzt').val() == '全部'
        })
        // 总体删除按钮绑定函数
        $('.bigdel').click(function () {
            let xjgoods = []
            let mycheck = document.querySelectorAll('.check')
            console.log(mycheck);
            for (let l = 0; l < mycheck.length; l++) {
                // console.log(123);
                if ($(mycheck[l]).attr('date-checked') == 'true') {
                    console.log(123);
                    xjgoods.push($(mycheck[l]).parent().parent().children(`td:nth-of-type(3)`).text())
                    console.log(xjgoods);
                }

            }

            // 数组去重
            function unique(arr) {
                for (var i = 0; i < arr.length; i++) {
                    for (var j = i + 1; j < arr.length; j++) {
                        if (arr[i] == arr[j]) {         //第一个等同于第二个，splice方法删除第二个
                            arr.splice(j, 1);
                            j--;
                        }
                    }
                }
                return arr;
            }

            let xjgoodsarry = unique(xjgoods)
            console.log(xjgoodsarry);
            // 遍历每一个数组元素，如果newdata里面的categoryName，为数组里面的值，就删除这一项
            after_salesData.forEach((item, index) => {
                for (var i in after_salesData[index]) {
                    for (let a = 0; a < xjgoodsarry.length; a++) {
                        // console.log(data[index][`${zt}`]);
                        if (after_salesData[index].account == xjgoodsarry[a]) {
                            after_salesData.splice(index, 1)

                        }
                    }

                }
            });

            var querydata = []
            showTable(6, after_salesData)
        })
    </script>
</body>

</html>